package logic

import (
	"context"
	"go/token"
	"work-safety/workrpc/workrpc"

	"work-safety/api/internal/svc"
	"work-safety/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type UploadLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewUploadLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UploadLogic {
	return &UploadLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *UploadLogic) Upload(req *types.UploadRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	data, err := l.svcCtx.WorkRpc.Upload(l.ctx, workrpc.UploadRequest{
		Account: "",
	})
	size := int()
	var ext string
	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Code:    500,
			Data:    nil,
		}, nil
	}

	if ext != "jpg" || ext != "webp" || ext != "sve" {
		return &types.Response{
			Message: "文件类型必须为JPG、WEBP、SVG 格式上传",
			Code:    500,
			Data:    nil,
		}, nil
	}

	if size == 1024*1024*5 {
		return &types.Response{
			Message: "上传最大限制为 5MB",
			Code:    500,
			Data:    nil,
		}, nil
	}
	return
}
